<?php
namespace app\index\controller;

class Search extends Base
{
    public function index()
    {
        $keyword = input('keywords');
        if ($keyword) {
            $map['keywords'] = ['like','%'.$keyword.'%'];
            $search = db('article')->where($map)->order('id desc')->paginate(3);
            $this->assign('search',$search);
            $this->assign('keyword',$keyword);
        } else {
            $this->assign('search',null);
            $this->assign('keyword','没有关键字');
        }
        return $this->fetch('search');
    }
}
